package com.ruoyi.web.controller.admin;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.web.entity.ApiCashFlow;
import com.ruoyi.web.service.IApiCashFlowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 充值流水信息Controller
 * 
 * @author youwei
 * @date 2023-11-28
 */
//@Api(tags = "管理后台 - {流水信息}")
@RestController
@RequestMapping("/web/flow")
public class ApiCashFlowController extends BaseController
{
    @Autowired
    private IApiCashFlowService apiCashFlowService;

    /**
     * 查询充值流水信息列表
     */
    @PreAuthorize("@ss.hasPermi('web:flow:list')")
    @GetMapping("/list")
    public TableDataInfo list(ApiCashFlow apiCashFlow)
    {
        startPage();
        List<ApiCashFlow> list = apiCashFlowService.selectApiCashFlowList(apiCashFlow);
        return getDataTable(list);
    }

    /**
     * 导出充值流水信息列表
     */
    @PreAuthorize("@ss.hasPermi('web:flow:export')")
    @Log(title = "充值流水信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ApiCashFlow apiCashFlow)
    {
        List<ApiCashFlow> list = apiCashFlowService.selectApiCashFlowList(apiCashFlow);
        ExcelUtil<ApiCashFlow> util = new ExcelUtil<ApiCashFlow>(ApiCashFlow.class);
        util.exportExcel(response, list, "充值流水信息数据");
    }

    /**
     * 获取充值流水信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('web:flow:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(apiCashFlowService.selectApiCashFlowById(id));
    }

    /**
     * 新增充值流水信息
     */
    @PreAuthorize("@ss.hasPermi('web:flow:add')")
    @Log(title = "充值流水信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ApiCashFlow apiCashFlow)
    {
        return toAjax(apiCashFlowService.insertApiCashFlow(apiCashFlow));
    }

    /**
     * 修改充值流水信息
     */
    @PreAuthorize("@ss.hasPermi('web:flow:edit')")
    @Log(title = "充值流水信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ApiCashFlow apiCashFlow)
    {
        return toAjax(apiCashFlowService.updateApiCashFlow(apiCashFlow));
    }

    /**
     * 删除充值流水信息
     */
    @PreAuthorize("@ss.hasPermi('web:flow:remove')")
    @Log(title = "充值流水信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(apiCashFlowService.deleteApiCashFlowByIds(ids));
    }
}
